<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %>
<%@ include file="./nav.jsp" %>
<div class="container">
    <div class="row">
        <div class="col-md-10 col-md-offset-1">
            <div>

                <!-- Nav tabs -->
                <ul class="nav nav-tabs" role="tablist">
                    <li role="presentation" class="active"><a href="#updatePass" aria-controls="updatePass" role="tab" data-toggle="tab">修改密码</a></li>
                    <li role="presentation"><a href="#updateHeadimg" aria-controls="updateHeadimg" role="tab" data-toggle="tab">修改头像</a></li>
                    <li role="presentation"><a href="#updateNickname" aria-controls="updateNickname" role="tab" data-toggle="tab">修改昵称</a></li>

                </ul>

                <!-- Tab panes -->
                <div class="tab-content">

                    <div role="tabpanel" class="tab-pane active" id="updatePass">
                        <div class="form-group">
                            <label for="inputPassword" class="col-sm-2 control-label manage-item">密码</label>
                            <div class="col-sm-10">
                                <input type="password" class="form-control manage-item" id="inputPassword" name="pass">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputPassword1" class="col-sm-2 control-label manage-item">重复密码</label>
                            <div class="col-sm-10">
                                <input type="password" class="form-control manage-item" id="inputPassword1" name="pass">
                            </div>
                            <button type="button" class="btn btn-default manage-item" onclick="changePass()">修改密码</button>
                        </div>

                    </div>
                    <div role="tabpanel" class="tab-pane" id="updateHeadimg">
                        <label for="inputPassword1" class="col-sm-2 control-label manage-item">修改头像</label>
                        <div class="col-sm-10">
                            <input type="file" class="form-control manage-item" id="inputHeadimg" name="headimg">
                        </div>
                        <button type="button" class="btn btn-default manage-item">修改头像</button>

                    </div>

                    <div role="tabpanel" class="tab-pane" id="updateNickname">
                        <div class="form-group">
                            <label for="inputNickname" class="col-sm-1 control-label manage-item">昵称</label>
                            <div class="col-sm-11">
                                <input type="text" class="form-control manage-item" id="inputNickname">
                            </div>
                            <button type="button" class="btn btn-default manage-item" onclick="changeNickName()">修改昵称</button>
                        </div>

                    </div>


                </div>

            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function changePass() {
        var pass = $("#inputPassword").val();
        var repeatPass = $("#inputPassword1").val();
        if (pass!=repeatPass){

            alert("两次密码不一致！")
        } else{
            $.post("${pageContext.request.contextPath}/api/user/updateUserInfo",{"password":pass},function (data) {
                if (data.success==1) {
                    alert("修改成功！");
                    window.location.reload();
                }else{
                    alert("修改失败！")

                }

            })
        }

    }
    
    function changeNickName() {
        var nickname = $("#inputNickname").val();
        $.post("${pageContext.request.contextPath}/api/user/updateUserInfo",{"nickname":nickname},function (data) {
            if (data.success==1) {
                alert("修改成功！");
                window.location.reload();
            }else{
                alert("修改失败！");
            }
        })
        
    }
</script>
</body>
</html>
